package zym.diandian.tools;

import android.content.Context;
import android.hardware.Sensor;
import android.hardware.SensorManager;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

public class OsHelper {

    private static final int[] sensorType = new int[]{Sensor.TYPE_ACCELEROMETER, Sensor.TYPE_MAGNETIC_FIELD, Sensor.TYPE_ORIENTATION, Sensor.TYPE_GYROSCOPE, Sensor.TYPE_LIGHT, Sensor.TYPE_PRESSURE, Sensor.TYPE_TEMPERATURE, Sensor.TYPE_PROXIMITY, Sensor.TYPE_GRAVITY, Sensor.TYPE_LINEAR_ACCELERATION, Sensor.TYPE_ROTATION_VECTOR};
    private static final String[] sensorName = new String[]{"加速度传感器", "磁场传感器", "方向传感器", "陀螺仪", "光传感器", "压力传感器", "温度传感器", "距离传感器", "重力传感器", "线性加速度传感器", "选择矢量"};


    public static List<HashMap<String, String>> getSensorList(Context conxt) {
        List<HashMap<String, String>> mList = new ArrayList<HashMap<String, String>>();

        SensorManager manager = (SensorManager) conxt.getSystemService(Context.SENSOR_SERVICE);
        List<Sensor> sensorList = manager.getSensorList(Sensor.TYPE_ALL);
        for (int i = 0; i < sensorList.size(); i++) {

            switch (sensorList.get(i).getType()) {
                case Sensor.TYPE_ACCELEROMETER:
                    HashMap<String, String> map = new HashMap<String, String>();
                    map.put("sensor", "加速度传感器");
                    mList.add(map);
                    break;
                case Sensor.TYPE_MAGNETIC_FIELD:
                    HashMap<String, String> map2 = new HashMap<String, String>();
                    mList.add(map2);
                    map2.put("sensor", "磁场传感器");
                    break;
                case Sensor.TYPE_ORIENTATION:
                    HashMap<String, String> map3 = new HashMap<String, String>();
                    map3.put("sensor", "方向传感器");
                    mList.add(map3);
                    break;
                case Sensor.TYPE_GYROSCOPE:
                    HashMap<String, String> map4 = new HashMap<String, String>();
                    map4.put("sensor", "陀螺仪");
                    mList.add(map4);
                    break;
                case Sensor.TYPE_LIGHT:
                    HashMap<String, String> map5 = new HashMap<String, String>();
                    map5.put("sensor", "光传感器");
                    mList.add(map5);
                    break;
                case Sensor.TYPE_PRESSURE:
                    HashMap<String, String> map6 = new HashMap<String, String>();
                    map6.put("sensor", "压力传感器");
                    mList.add(map6);
                    break;
                case Sensor.TYPE_TEMPERATURE:
                    HashMap<String, String> map7 = new HashMap<String, String>();
                    map7.put("sensor", "温度传感器");
                    mList.add(map7);
                    break;
                case Sensor.TYPE_PROXIMITY:
                    HashMap<String, String> map8 = new HashMap<String, String>();
                    map8.put("sensor", "距离传感器");
                    mList.add(map8);
                    break;
                case Sensor.TYPE_GRAVITY:
                    HashMap<String, String> map9 = new HashMap<String, String>();
                    map9.put("sensor", "重力传感器");
                    mList.add(map9);
                    break;
                case Sensor.TYPE_LINEAR_ACCELERATION:
                    HashMap<String, String> map10 = new HashMap<String, String>();
                    map10.put("sensor", "线性加速度传感器");
                    mList.add(map10);
                    break;
                case Sensor.TYPE_ROTATION_VECTOR:
                    HashMap<String, String> map11 = new HashMap<String, String>();
                    map11.put("sensor", "旋转矢量");
                    mList.add(map11);
                    break;
                default:
                    break;
            }
        }
        // 10-28 20:10:28.483: D/tools.Tool8.getSensorList().16(14583): Sensor :
        // LIS3DH //加速度
        // 10-28 20:10:28.483: D/tools.Tool8.getSensorList().16(14583): Sensor :
        // AK8963
        // 10-28 20:10:28.483: D/tools.Tool8.getSensorList().16(14583): Sensor :
        // Orientation
        // 10-28 20:10:28.483: D/tools.Tool8.getSensorList().16(14583): Sensor :
        // BMP180
        // 10-28 20:10:28.483: D/tools.Tool8.getSensorList().16(14583): Sensor :
        // ISL29028
        // 10-28 20:10:28.483: D/tools.Tool8.getSensorList().16(14583): Sensor :
        // ISL29028
        // 10-28 20:10:28.483: D/tools.Tool8.getSensorList().16(14583): Sensor :
        // L3GD20
        // 10-28 20:10:28.483: D/tools.Tool8.getSensorList().16(14583): Sensor :
        // BMP180
        // 10-28 20:10:28.493: D/tools.Tool8.getSensorList().16(14583): Sensor :
        // Gravity
        // 10-28 20:10:28.493: D/tools.Tool8.getSensorList().16(14583): Sensor :
        // Linear Acceleration
        // 10-28 20:10:28.493: D/tools.Tool8.getSensorList().16(14583): Sensor :
        // AMD
        // 10-28 20:10:28.493: D/tools.Tool8.getSensorList().16(14583): Sensor :
        // RMD
        // 10-28 20:10:28.503: D/tools.Tool8.getSensorList().16(14583): Sensor :
        // VMD
        // 10-28 20:10:28.503: D/tools.Tool8.getSensorList().16(14583): Sensor :
        // Rotation Vector

        return mList;
    }

    public static String[] getBatteryInfo() {
        String result[] = new String[7];
        result[0] = BatteryInfo.getDl();
        result[1] = BatteryInfo.getDy();
        result[2] = BatteryInfo.getWd();
        result[3] = BatteryInfo.getLx();
        result[4] = BatteryInfo.getJk();
        result[5] = BatteryInfo.getZt();
        result[6] = BatteryInfo.getCd();
        return result;
    }
}
